<template>
  <div>
    <Header></Header>
    <div class="container">
      <div class="header">
        <p>订单确认</p>
        <el-steps
          :active="active"
          finish-status="success"
          class="steps"
          :align-center="true"
        >
          <el-step title="购物车" />
          <el-step title="订单确认" />
          <el-step title="订单完成" />
        </el-steps>
        <p></p>
      </div>
      <div class="main">
        <div class="left">
          <div class="left-top">
            <div class="title">
              <p>收件信息</p>
              <p>新增地址</p>
            </div>
            <div class="content">
              <ul>
                <li
                  v-for="item in dataSource"
                  :key="item.id"
                  @click="chooseAddress(item.id)"
                  :style="{
                    border:
                      selectedAddress == item.id ? '1px solid #c10000' : '',
                  }"
                >
                  <div class="header">
                    <p>姓名：{{ item.userName }}</p>
                    <div>
                      <span>设为默认</span>
                      <span>删除</span>
                      <span>编辑</span>
                    </div>
                  </div>
                  <div class="content">
                    <p>地址：{{ item.address }}</p>
                    <p>手机号：{{ item.phone }}</p>
                  </div>
                </li>
              </ul>
            </div>
          </div>
          <div class="left-middle">
            <div class="header">支付方式</div>
            <div class="content">
              <img
                src="@/static/images/shopping-cart/way01.jpg"
                alt=""
                @click="chooseWay(1)"
                :style="{
                  border: selectedWay == 1 ? '1px solid #c10000' : '',
                }"
              />
              <img
                src="@/static/images/shopping-cart/way02.jpg"
                alt=""
                @click="chooseWay(2)"
                :style="{
                  border: selectedWay == 2 ? '1px solid #c10000' : '',
                }"
              />
              <img
                src="@/static/images/shopping-cart/way03.jpg"
                alt=""
                @click="chooseWay(3)"
                :style="{
                  border: selectedWay == 3 ? '1px solid #c10000' : '',
                }"
              />
              <img
                src="@/static/images/shopping-cart/way04.jpg"
                alt=""
                @click="chooseWay(4)"
                :style="{
                  border: selectedWay == 4 ? '1px solid #c10000' : '',
                }"
              />
            </div>
          </div>
          <div class="left-bottom">
            <div class="header">选择快递</div>
            <div class="content">
              <div
                @click="chooseExpress(1)"
                :style="{
                  border: selectedExpress == 1 ? '1px solid #c10000' : '',
                }"
              >
                顺丰快递
              </div>
              <div
                @click="chooseExpress(2)"
                :style="{
                  border: selectedExpress == 2 ? '1px solid #c10000' : '',
                }"
              >
                百世汇通
              </div>
              <div
                @click="chooseExpress(3)"
                :style="{
                  border: selectedExpress == 3 ? '1px solid #c10000' : '',
                }"
              >
                圆通快递
              </div>
              <div
                @click="chooseExpress(4)"
                :style="{
                  border: selectedExpress == 4 ? '1px solid #c10000' : '',
                }"
              >
                货到付款
              </div>
            </div>
          </div>
        </div>
        <div class="right">
          <div class="header">
            <p>订单内容</p>
            <a href="">返回购物车</a>
          </div>
          <ul>
            <li>
              <div class="goods">
                <img src="@/static/images/shopping-cart/order01.jpg" alt="" />
                <div class="desc">
                  <p>创意现代简约干花花瓶摆件</p>
                  <p>颜色分类：烟灰色玻璃瓶</p>
                  <p>数量：1</p>
                </div>
              </div>
              <div class="price">￥69.00</div>
            </li>
            <li>
              <div class="goods">
                <img src="@/static/images/shopping-cart/order02.jpg" alt="" />
                <div class="desc">
                  <p>创意现代简约干花花瓶摆件</p>
                  <p>颜色分类：烟灰色玻璃瓶</p>
                  <p>数量：1</p>
                </div>
              </div>
              <div class="price">￥69.00</div>
            </li>
          </ul>
          <div class="text">
            <p><span>商品金额：</span><span>￥138.00</span></p>
            <p><span>优惠金额：</span><span>￥0.00</span></p>
            <p><span>运费：</span><span>免运费</span></p>
          </div>
          <div class="total">
            <p>合计：</p>
            <p>￥138.00</p>
          </div>
          <el-button>去支付</el-button>
        </div>
      </div>
    </div>
    <Tabbar></Tabbar>
    <Footer></Footer>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from 'vue';
import Header from '@/components/header/index.vue';
import Footer from '@/components/footer/index.vue';
import Tabbar from '@/components/tabbar/index.vue';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const data = require('@/mock/personal/my-address.json');

export default defineComponent({
  components: { Header, Footer, Tabbar },
  setup() {
    const active = ref(1);
    const dataSource = computed(() => {
      return data.data;
    });

    const selectedAddress = ref();
    const selectedWay = ref();
    const selectedExpress = ref();
    return {
      active,
      dataSource,
      selectedAddress,
      selectedWay,
      selectedExpress,
    };
  },
  methods: {
    chooseAddress(id: number) {
      this.selectedAddress = id;
    },
    chooseWay(id: number) {
      this.selectedWay = id;
    },
    chooseExpress(id: number) {
      this.selectedExpress = id;
    },
  },
});
</script>

<style lang="scss" scoped>
.container {
  width: 1163px;
  margin: 0 auto;
  padding-top: 10px;

  .header {
    width: 100%;
    height: 62px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    //border-bottom: 1px solid #ddd;

    .steps {
      width: 450px;

      ::v-deep .el-step__icon.is-text {
        font-size: 12px;
      }
      ::v-deep .el-step__title {
        font-size: 12px;
      }
    }
  }

  .main {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    .left {
      width: 700px;
      margin-bottom: 20px;
    }

    .right {
      width: 416px;
    }
  }
}

.left {
  .left-top {
    .title {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #ddd;
      font-size: 16px;
      color: #444;
      padding: 8px 0px;
    }

    .content ul {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      li {
        width: 329px;
        height: 150px;
        border: 1px solid #ddd;
        margin-top: 20px;
        cursor: pointer;

        .header {
          height: 45px;
          width: 100%;
          line-height: 45px;
          font-size: 13px;
          padding: 0 8px;
          box-sizing: border-box;

          span {
            display: inline-block;
            margin-left: 16px;
            position: relative;
            cursor: pointer;

            &:last-child::after {
              content: '';
              display: inline-block;
              width: 1px;
              height: 13px;
              background-color: #666;
              position: absolute;
              top: 16px;
              left: -8px;
            }
          }
        }

        .content {
          line-height: 52.5px;
          padding: 0 8px;
          background-color: rgba(225, 225, 225, 0.5);
          font-size: 12px;
        }
      }
    }
  }

  .left-middle .header,
  .left-bottom .header {
    height: 32px;
    border-bottom: 1px solid #ddd;
    font-size: 16px;
    color: #444;
    padding: 8px 0px;
  }

  .left-middle .content,
  .left-bottom .content {
    display: flex;
    justify-content: space-between;
    margin-top: 18px;
  }

  .left-middle .content img {
    display: inline-block;
    border: 1px solid #ddd;
    cursor: pointer;
  }

  .left-bottom .content div {
    display: inline-block;
    padding: 6px 18px;
    border: 1px solid #ddd;
    cursor: pointer;
  }
}

.right {
  .header {
    height: 48px;
    display: flex;
    justify-content: space-between;
    justify-items: center;
    border-bottom: 1px solid #ddd;
    background-color: rgba(225, 225, 225, 0.5);
    padding: 0 8px;
    box-sizing: border-box;

    p {
      font-size: 16px;
    }
    a {
      font-size: 12px;
    }
  }

  ul {
    width: 100%;
    li {
      height: 84px;
      display: flex;
      padding: 8px 12px;
      justify-content: space-between;
      background-color: rgba(225, 225, 225, 0.5);

      &:not(:last-child) {
        border-bottom: 1px solid #ddd;
      }

      .goods {
        display: flex;
        img {
          height: 84px;
        }

        .desc {
          margin-left: 6px;
          font-size: 12px;
          color: #999;
          line-height: 28px;

          p {
            &:first-child {
              font-weight: 700;
              color: #000;
            }
          }
        }
      }

      .price {
        line-height: 84px;
      }
    }
  }

  .text {
    font-size: 12px;
    color: #666;
    border-bottom: 1px solid #ddd;
    p {
      display: flex;
      justify-content: space-between;
      height: 28px;
      line-height: 28px;
      span {
        display: block;
      }
    }
  }

  .total {
    height: 68px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    p {
      &:last-child {
        color: red;
      }
    }
  }

  ::v-deep .el-button {
    width: 100%;
    height: 40px;
    background-color: #c10000;
    color: white;
  }
}

.active-class {
  color: red;
  border: 1px solid #c10000;
}
</style>
